﻿/**********************************************************************
 * @file   FITKAcousticsVTKGraphObjectMergedData.h
 * @brief  合并数据渲染基类
 * @author BaGuijun (baguijun@163.com)
 * @date   2025-03-05
 *********************************************************************/
#ifndef __FITKACOUSTICSVTKGRAPHOBJECTMERGEDDATA_H__
#define __FITKACOUSTICSVTKGRAPHOBJECTMERGEDDATA_H__

#include "FITKAcousticsVTKGraphObject3DPost.h"

#include "FITKAcousticsVTKGraphAdaptorAPI.h"

// Forward declaration
class vtkCompositeDataGeometryFilter;
class vtkExtractBlock;
class vtkMultiBlockDataSet;

class FITKAcousticsVTKGraphActor;

namespace Acoustics
{
    class FITKAcousticsSEAModel;
    class FITKAbstractSEASubSys;
}

namespace Exchange
{
    class FITKAcousticsVTKGraphObjectSEASelectMergedData;
}

namespace Exchange
{
    /**
     * @brief  合并数据渲染基类
     * @author BaGuijun (baguijun@163.com)
     * @date   2025-03-05
     */
    class FITKACOUSTICSGRAPHADAPTORAPI FITKAcousticsVTKGraphObjectMergedData : public FITKAcousticsVTKGraphObject3DPost
    {
        // Regist
        FITKGraphObjectRegist(FITKAcousticsVTKGraphObjectMergedData, FITKAcousticsVTKGraphObject3DPost);
        FITKCLASS(Exchange, FITKAcousticsVTKGraphObjectMergedData);
    public:
        /**
         * @brief    构造函数
         * @param[i] dataObj                      数据对象
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-03-05
         */
        FITKAcousticsVTKGraphObjectMergedData(Core::FITKAbstractDataObject* dataObj);

        /**
         * @brief   Destructor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual ~FITKAcousticsVTKGraphObjectMergedData();

        /**
         * @brief   Update all graph actors.[virtual][override]
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void update(bool forceUpdate = false) override;

        /**
         * @brief   Update the visibility with data object's visibility.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void updateVisibility() override;

        /**
         * @brief   Update all graph actors by the given data id.[virtual][override]
         * @param   dataId: The data id need to be update
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void updateById(int dataId, bool forceUpdate = false) override;

        /**
         * @brief   Update all graph actors by the given data ids.[virtual][override]
         * @param   dataIds: The data ids need to be update
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void updateByIds(QList<int> dataIds, bool forceUpdate = false) override;
        /**
         * @brief    高亮渲染对象
         * @param[i] hightObjID                     高亮数据id【仅复合数据使用】
         * @param[i] type                           需要突出显示形状类型
         * @param[i] color                          高亮颜色
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-02-05
         */
        void highlight(int hightObjID = -1, FITKAcousticsVTKCommons::ShapeType type = FITKAcousticsVTKCommons::ShapeTypeNone, QColor color = QColor()) override;
        /**
         * @brief    取消高亮渲染对象
         * @param[i] hightObjID                     取消高亮数据id【仅复合数据使用】
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-02-05
         */
        void disHighlight(int hightObjID = -1) override;
        /**
         * @brief    设置是否开启色对数颜色映射
         * @param[i] isOn                         是否开启
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-03-05
         */
        void setEnableLogScale(bool isOn) override;
        /**
         * @brief    修改标量色带数量
         * @param[i] num                          数量
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-03-06
         */
        void setScalarNumber(int num) override;
        /**
         * @brief    设置范围的最大、最小颜色与透明度
         * @param[i] minRangeColor                  最小值颜色
         * @param[i] maxRangeColor                  最大值颜色
         * @param[i] transparency                   透明度
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-03-06
         */
        void setRangeColor(QColor minRangeColor, QColor maxRangeColor, double transparency) override;
        /**
         * @brief    设置超出范围的颜色
         * @param[i] color                            颜色
         * @param[i] transparency                     透明度（0-1）
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-03-06
         */
        void setAboveRangeColor(QColor color, double transparency) override;
        /**
         * @brief    设置低于范围的颜色
         * @param[i] color                            颜色
         * @param[i] transparency                     透明度（0-1）
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-03-06
         */
        void setBelowRangeColor(QColor color, double transparency) override;

        /**
         * @brief   Advanced highlight mode for highlighting part of the graph actors.[virtual][override]
         * @param   type: The type of the model need to be highlighted
         * @param   indice: The given indice of the model component need to be highlight
         * @param   color: The given color for highlighting this time[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void advanceHighlight(FITKAcousticsVTKCommons::ShapeType type, QVector<int> indice, QColor color = QColor()) override;

        /**
         * @brief   Dis-highlight the graph actors if the graph object is in advanced highlighting mode.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void disAdvanceHighlight() override;

        /**
         * @brief   Set if the graph object pickable mode.[virtual][override]
         * @param   mode: The pickable mode
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void setPickMode(FITKAcousticsVTKCommons::ShapePickMode mode) override;

        /**
         * @brief   Get the shape id by the given shape type and VTK cell id.[virtual][override]
         * @param   vtkId: The VTK point or cell id in shape data
         * @param   topAbsShapeType: The shape type of the given ID( the same as TopAbs_ShapeEnum )
         * @return  The shape id
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual int getShapeIdByVTKCellId(int vtkId, FITKAcousticsVTKCommons::ShapeMeshAbsEnum topAbsShapeType) override;

    protected:
        /**
         * @brief   Intialize.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void init();

        /**
         * @brief   Generate the multi block dataset for the sub-systems.[pure virtual]
         * @return  Is the data valid
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual bool generateDataSet() = 0;

        /**
         * @brief   Generate the actor with the sub-system data.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void generateGraph();

    protected:
        /**
         * @brief   The highlightor of the merged dataset.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        FITKAcousticsVTKGraphObjectSEASelectMergedData* m_highlightSelector{ nullptr };

        /**
         * @brief   The filter for merging multi block dataset.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        vtkCompositeDataGeometryFilter* m_comp2Poly{ nullptr };
        /**
         * @brief  当前显示的数据组（是全部数据的子集）
         * @author BaGuijun (baguijun@163.com)
         * @date   2024-12-25
         */
        vtkMultiBlockDataSet* m_multiBlockDataSet = nullptr;
        /**
         * @brief   The filter for extracting the blocks of the multi block dataset.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-20
         */
        vtkExtractBlock* m_extractBlock{ nullptr };

        /**
         * @brief   The actor for the grid.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        FITKAcousticsVTKGraphActor* m_fActor{ nullptr };
        /**
         * @brief  高亮复合数据提取器
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-02-05
         */
        vtkCompositeDataGeometryFilter* m_comp2PolyHight = nullptr;
        /**
         * @brief  高亮数据块
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-02-05
         */
        vtkMultiBlockDataSet* m_multiBlockHightDataSet = nullptr;
        /**
         * @brief  高亮数据块过滤器
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-02-05
         */
        vtkExtractBlock* m_extractBlockHight = nullptr;
        /**
         * @brief  高亮演员
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-02-05
         */
        FITKAcousticsVTKGraphActor* m_fActorHight = nullptr;
        /**
         * @brief  高亮列表
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-02-05
         */
        QList<int> m_hightObjIdList = {};
    };
}   // namespace Exchange

#endif // __FITKACOUSTICSVTKGRAPHOBJECTMERGEDDATA_H__
